/********************************************************
 * Filename: Model.java
 * Author: LMU
 * Program: TUnit
 * Description: Main class used for Namespace Explorer.  
 * Revision History:
 * 20060904: Initial revision.  Added header later.  
 * *****************************************************/

package edu.lmu.cs.tUnit.view.model;

import org.eclipse.core.resources.IProject;

public abstract class Model {
	protected TclNamespace parent;
	protected String name;
	protected String fileName;	
	protected IProject project;
	protected IDeltaListener listener = NullDeltaListener.getSoleInstance();
	
	protected void fireAdd(Object added) {
		listener.add(new DeltaEvent(added));
	}

	protected void fireRemove(Object removed) {
		listener.remove(new DeltaEvent(removed));
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public TclNamespace getParent() {
		return parent;
	}
	
	/* The receiver should visit the toVisit object and
	 * pass along the argument. */
	public abstract void accept(IModelVisitor visitor, Object passAlongArgument);
	
	public String getName() {
		return name;
	}
	
	public void addListener(IDeltaListener listener) {
		this.listener = listener;
	}
	
	public Model(String procName, String fileName, IProject project) {
		this.name = procName;
		this.fileName = fileName;
		this.project = project;
	}
	
	public Model() {
	}	
	
	public void removeListener(IDeltaListener listener) {
		if(this.listener.equals(listener)) {
			this.listener = NullDeltaListener.getSoleInstance();
		}
	}

	public String getFileName() {
		return fileName;
	}

	public String getTitle() {
		return name;
	}
	
	public IProject getProject() {
		return project;
	}
}
